package com.atguigu.schedule.service.impl;

import com.atguigu.schedule.dao.SysUserDao;
import com.atguigu.schedule.dao.impl.SysUserDaoImpl;
import com.atguigu.schedule.pojo.SysUser;
import com.atguigu.schedule.service.SysUserService;
import com.atguigu.schedule.util.MD5Util;

/**
 * @author yuezi2048
 * @version 1.0
 */
public class SysUserServiceImpl implements SysUserService {
    private SysUserDao userDao = new SysUserDaoImpl();

    @Override
    public int register(SysUser sysUser) {
        // 将用户的明文密码转化成密文密码
        sysUser.setUserPwd(MD5Util.encrypt(sysUser.getUserPwd()));

        // 调用Dao, 将sysUser信息存入数据库(可以将Dao对象单独定义到外面去 new一次就行)
        return userDao.addSysUser(sysUser);
    }

    @Override
    public SysUser findUserName(String username) {
        return userDao.findByUsername(username);
    }
}
